@extends('layout.default')

@section('layout.content')

  <div class="row">
    <div class="col-xs-12 align-right">
      <div style="margin-bottom: 15px;">
        <a href="{{route('act.lists')}}" class="btn btn btn-success list-act"><i class="ace-icon fa fa-list"></i> 新春活动列表</a>
        <button class="btn btn btn-danger create-act"><i class="ace-icon fa fa-bookmark"></i> 新建活动</button>
      </div>
    </div>
  </div><!-- /.row -->

  <div class="row">
    <div class="col-xs-12">
      <table class="table table-hover table-striped table-bordered nonborder">
        <thead>
        <tr>
          <th class="center">序号</th>
          <th class="align-middle" style="min-width:240px;">活动名称</th>
          <th class="center">题型</th>
          <th class="center">题数</th>
          <th class="center">答题</th>
          <th class="center">状态</th>
          <th class="align-left">UUID</th>
          <th class="align-right" style="width:110px;">创建日期</th>
        </tr>
        </thead>
        <tbody>
          @foreach ($topics as $i=>$topic)
          <tr class="bank">
            <td class="center">
              <span class="smaller-80">{{$i+1}}</span>
            </td>
            <td class="align-middle">
                <a href="javascript:;" class="edit-act" data-tid="{{$topic->id}}"><i class="ace-icon fa fa-edit"></i></a>
                <a href="{{route('act.question.index', $topic->id)}}">{{ $topic->name }}</a>
            </td>
            <td class="center">{!! $topic->present()->tType !!}</td>
            <td class="center">{{ $topic->questions_count }}</td>
            <td class="center"><a href="{{route('act.view',$topic->id)}}">{{ $topic->joins_count }}</a></td>
            <td class="center">{!! $topic->present()->tStatus !!}</td>
            <td class="align-left">{{ $topic->token }}</td>
            <td class="align-right"><span class="grey smaller-80">{{ date('Y-m-d',strtotime($topic->created_at)) }}</span></td>
        
          </tr>
          @endforeach
        </tbody>
      </table>
    </div>

  </div>

  <div class="row">
    <div class="col-xs-12">
      <div class="dataTables_paginate paging_bootstrap">{{ $topics->links() }}</div>
    </div>
  </div>
@stop
@section('javascript')
<script type="text/javascript">
    $(function () {

        $('.create-act').on('click', function(e) {
            layer.open({
            type: 2,
            title: '新增专题活动',
            area: ['400px', '550px'],
            shade: 0.8,
            content: "{{route('act.create')}}",
            });
        });

        $('.edit-act').on('click', function(e) {
          var tid = $(this).data('tid');
            layer.open({
            type: 2,
            title: '修改专题活动',
            area: ['400px', '550px'],
            shade: 0.8,
            content:"/act/edit/"+tid,
            });
        });

    });
</script>
@stop
